package pass;

import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import java.util.Random;
import java.util.regex.Pattern;

public class PasswordUtil {

    private static final String[] WORD = {
            "a", "b", "c", "d", "e", "f", "g", "h", "j", "k", "m", "n", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z",
            "A", "B", "C", "D", "E", "F", "G", "H", "J", "K", "M", "N", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z",
            "0", "1", "2", "3", "4", "5", "6", "7", "8", "9",
            "@", "#", "$", "%", "^", "&", "*"
    };

    private PasswordUtil() {
    }

    public static String randomPassword(int length) throws NoSuchAlgorithmException {
        StringBuilder builder = new StringBuilder();
        Random random = SecureRandom.getInstanceStrong();
        for (int i = 0; i < length; i++) {
            int value = random.nextInt(WORD.length);
            builder.append(WORD[value]);
        }
        return builder.toString();
    }

    public static void main1(String[] args) throws NoSuchAlgorithmException {
        for(int i =0; i< 100; i++) {
            System.out.println(randomPassword(8));
        }
    }

    static String regex1=".*\\d+.*";

    static String regex2 = ".*[a-zA-Z]+.*";

    static String regex3 = ".*[@#$%^&*]+.*";

    public static void main2(String[] args) {

        String pwd = "sxzMcqrq";
        System.out.println(Pattern.matches(regex1, pwd));
        System.out.println(Pattern.matches(regex2, pwd));
        System.out.println(Pattern.matches(regex3, pwd));
        System.out.println(Pattern.matches(regex1, pwd)&&Pattern.matches(regex2, pwd)&&Pattern.matches(regex3, pwd));

    }


    public static void main(String[] args) {
        Long a =0L;
        System.out.println(a.equals(0L));
    }

}
